package com.ruoyi.shopping.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.shopping.domain.MallShoppingCart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shopping.mapper.MallShoppingCartMapper;
import com.ruoyi.shopping.service.IMallShoppingCartService;

/**
 * 购物车Service业务层处理
 *
 * @author scx
 * @date 2022-06-09
 */
@Service
public class MallShoppingCartServiceImpl implements IMallShoppingCartService
{
    @Autowired
    private MallShoppingCartMapper mallShoppingCartMapper;

    /**
     * 查询购物车
     *
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public MallShoppingCart selectMallShoppingCartById(Long id)
    {
        return mallShoppingCartMapper.selectMallShoppingCartById(id);
    }

    /**
     * 查询购物车列表
     *
     * @param mallShoppingCart 购物车
     * @return 购物车
     */
    @Override
    public List<MallShoppingCart> selectMallShoppingCartList(MallShoppingCart mallShoppingCart)
    {
        return mallShoppingCartMapper.selectMallShoppingCartList(mallShoppingCart);
    }

    /**
     * 新增购物车
     *
     * @param mallShoppingCart 购物车
     * @return 结果
     */
    @Override
    public int insertMallShoppingCart(MallShoppingCart mallShoppingCart)
    {
        mallShoppingCart.setCreateTime(DateUtils.getNowDate());
        return mallShoppingCartMapper.insertMallShoppingCart(mallShoppingCart);
    }

    /**
     * 修改购物车
     *
     * @param mallShoppingCart 购物车
     * @return 结果
     */
    @Override
    public int updateMallShoppingCart(MallShoppingCart mallShoppingCart)
    {
        mallShoppingCart.setUpdateTime(DateUtils.getNowDate());
        return mallShoppingCartMapper.updateMallShoppingCart(mallShoppingCart);
    }

    /**
     * 批量删除购物车
     *
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteMallShoppingCartByIds(Long[] ids)
    {
        return mallShoppingCartMapper.deleteMallShoppingCartByIds(ids);
    }


    /**
     * 批量逻辑删除购物车
     *
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int logicDeleteMallShoppingCart(Long[] ids,String delType,Long delUser)
    {
        return mallShoppingCartMapper.logicDeleteMallShoppingCart(ids,delType,delUser);
    }

    /**
     * 删除购物车信息
     *
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteMallShoppingCartById(Long id)
    {
        return mallShoppingCartMapper.deleteMallShoppingCartById(id);
    }

    @Override
    public List<MallShoppingCart> selectCount(Long specsId, Long loginMemberId) {
        return mallShoppingCartMapper.selectCount(specsId,loginMemberId);
    }

    @Override
    public MallShoppingCart selectMallShoppingCart(MallShoppingCart cart) {
        return mallShoppingCartMapper.selectMallShoppingCart(cart);
    }

    @Override
    public void deleteBySpecsIds(List<Long> collect, Long loginMemberId) {
        mallShoppingCartMapper.deleteBySpecsIds(collect,loginMemberId);
    }
}
